package org.jeecg.config.cxf;


import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.jeecg.modules.tdm.webService.FileWebService;
import org.jeecg.modules.tdm.webService.FileWebServiceImpl;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;


/*
 * WebServiceConfig配置发布服务
 * */
@Configuration
public class WebServiceConfig {



	//WebServiced发布调用接口
	@Bean
	public ServletRegistrationBean<CXFServlet> createServletRegistrationBean() {
		System.out.println("dispatcherServlet");
		return new ServletRegistrationBean<CXFServlet>(new CXFServlet(), "/services/*");//自己的WebService根访问路径
	}



	@Bean(name = Bus.DEFAULT_BUS_ID)
	public SpringBus springBus() {
		return new SpringBus();
	}

	//注册服务
	@Bean
	public FileWebService FileWebService() {
		return new FileWebServiceImpl();
	}



	//发布服务
	@Bean
	public Endpoint endpointLogin() {
		EndpointImpl endpoint = new EndpointImpl(springBus(), FileWebService());
		endpoint.publish("/FileWebService");//接口前缀路径
		return endpoint;
	}
}

